﻿#ifndef LOGTHREAD_H
#define LOGTHREAD_H

#include <QThread>
#include <QQueue>
#include <QDir>
#include <QDateTime>
#include <QSemaphore>
#include <QDebug>
#include <QMutex>


#define DEBUG_SOFTWARE_NAME "NIDCS"


// 把消息写到txt里面
class LogThread : public QThread
{
public:
    LogThread();



    struct stLog{
        QString type;
        QString text;
        stLog(QString text, QString type){
            this->type = type;
            this->text = text;
        }
    };

    void run() override;


    void write(QString text, QString type = "");


private:

    void deleteHistoryLog();


    QMutex              _queueMutex;
    QQueue<stLog>       _logQueue;
    QSemaphore          _semaphore_logCount;

    QString             _outRootDir;
    int                 _deleteTime = 10;       // 删除天数间隔

};

#endif // LOGTHREAD_H
